<?php
error_reporting(E_ALL ^ E_STRICT);
class AjaxController extends ControllerBase
{
   public function suggesAction()
   {
      $this->view->disable();
      //$keyword = getValue('query','str','GET','',2);
      $request = new Phalcon\Http\Request();
      if ($request->isGet() == true) {
          if ($request->isAjax() == true) {
              $keyword = $request->getQuery('query',null,'');
               $sug = Sugges::find(array(
                  "sp_name LIKE '%$keyword%'",
                  "order" => "sp_name",
                  "limit" => 10
               ));
               $arr_sg = array();
               foreach ($sug as $value) {
                  $arr_sg['suggestions'][] = $value->sp_name;
               }
               echo json_encode($arr_sg);die; 
          }else {
               die('Access denied');
          }
      }else {
         die('Access denied');
      }
   }
}